package com.gitee.loyo.jdbc

import java.sql.PreparedStatement

data class StmtOptions(
    val fetchSize: Int? = null,
    val fetchDirection: Int? = null,
    val queryTimeout: Int? = null,
    val isPoolable: Boolean? = null,
    val largeMaxRows: Long? = null,
    val maxFieldSize: Int? = null,
    val maxRows: Int? = null,
    val returnGeneratedKeys: Boolean = false,
){
    fun populate(stmt: PreparedStatement): PreparedStatement{
        if(fetchSize != null)
            stmt.fetchSize = fetchSize
        if(fetchDirection != null)
            stmt.fetchDirection = fetchDirection
        if(queryTimeout != null)
            stmt.queryTimeout = queryTimeout
        if(isPoolable != null)
            stmt.isPoolable = isPoolable
        if(largeMaxRows != null)
            stmt.largeMaxRows = largeMaxRows
        if(maxFieldSize != null)
            stmt.maxFieldSize = maxFieldSize
        if(maxRows != null)
            stmt.maxRows = maxRows
        return stmt
    }
}